package com.telecom.cms.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.telecom.cms.util.Constant;
import com.telecom.cms.dto.*;

public class SEG_VALUE_TYPE_DEFDAO {

	private static final String SQL_FINDBYID = "select * from "
			+ Constant.SEG_BOOKMARK_DEF
			+ " where CLASS_ID = ? order by BOOKMARK_ID ";

	private Connection conn = null;

	public SEG_VALUE_TYPE_DEFDAO(Connection con) {

		this.conn = con;

	}

	public List findById(int id) {
		PreparedStatement ps = null;
		ResultSet rs = null;
		List list = new ArrayList();
		try {
			ps = conn.prepareStatement(SQL_FINDBYID);
			ps.setInt(1, id);
			rs = ps.executeQuery();
			while (rs.next()) {
				SEG_BOOKMARK_DEFDTO dto = new SEG_BOOKMARK_DEFDTO();
				dto.setBOOKMARK_ID(rs.getInt(1));
				dto.setBOOKMARK_NAME(rs.getString(2));
				dto.setBOOKMARK_DESC(rs.getString(3));
				dto.setIS_USERD(rs.getString(4));
				dto.setIMAGE_URL(rs.getString(5));
				dto.setCLASS_ID(rs.getInt(6));
				dto.setCREATE_TIME(rs.getTimestamp(7));
				dto.setUSER_ID(rs.getString(8));
				list.add(dto);
			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				if (rs != null) {

					rs.close();
				}
				if (ps != null) {
					ps.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return list;
	}

}
